Repository navigation
🐛 fix(shims): bound version file reads - #209
Merged
gaborbernat merged 3 commits intoNov 3, 2026
Merged
gaborbernat merged 3 commits into
gaborbernat merged 3 commits into
Conversation
A version file in a shared parent directory could exhaust the caller's memory during shim resolution. Skip files over 4096 characters so discovery can continue with another version source.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_versions_in_file()read an entire version file while resolving a version-manager shim. A file in a shared parent directory could make the caller allocate memory proportional to its length. The reader now caps input at 4096 characters and skips larger files. This addresses draft advisory ANT-2026-WXCONOWU.Version file reads
pyenv searches the working directory and its parents for
.python-version._active_versions()uses the same search, and the old reader iterated without a length limit. The reader now requests at most 4097 characters to distinguish an allowed file from an oversized one without reading the rest. It splits only newline characters, preserving version names that contain other Unicode separators.Behavior changes
Files over 4096 characters no longer select a version. Discovery checks parent directories and, for pyenv, its global version when available. Files within the limit keep their existing parsing behavior, including replacement of undecodable bytes.
Reported by Antigravity: ANT-2026-WXCONOWU.